#
# Copyright (C) 2013 Will Dignazio
#
ROOTDIR = $(PWD)
PREFIX	= $ROOTDIR

CC	= clang
CFLAGS	= -O0 -g -Wall -Werror -I $(ROOTDIR)/include/
LIBS	= -lzmq -lconfig

ULIBS	= libtalk \
	  libutil
CSRC	= 

HEADERS	= internal.h	\
	  include/*.h	\

COBJ	= $(CSRC:.c=.o)
CLIBS	= $(ULIBS:=.a)

export ROOTDIR
export CFLAGS
export CC

.PHONY: all clean util

all: $(COBJ) $(CLIBS)
	$(CC) $(CFLAGS) $(LIBS) -o coalesced coalesced.c $(CLIBS)

%.o: %.c internal.h
	$(CC) $(CFLAGS) -c -o $@ $<

%.a:
	export LOCALDIR=$(ROOTDIR)/$*
	$(MAKE) $(MAKEFLAGS) -C $*
	cp $*/$@ ./

clean:
	@for lib in $(ULIBS); do	\
		$(MAKE) -C $$lib clean;	\
	done
	rm -f coalesced
	rm -f *.a
	rm -f *.o
